package com.lz.gmall.product.controller;

import com.lz.gmall.common.result.Result;
import com.lz.gmall.common.result.ResultCodeEnum;
import com.lz.gmall.product.entity.SpuImage;
import com.lz.gmall.product.service.SpuImageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin/product")
@Api(tags = "图片操作")
public class SpuImageController {

    @Autowired
    private SpuImageService spuImageService;

    /**
     * 根据spuId获取图片列表
     * @param spuId
     * @return
     */
    @GetMapping("/spuImageList/{spuId}")
    @ApiOperation("根据spuId获取图片列表")
    public Result<List<SpuImage>> getSpuImageList(@PathVariable("spuId")Long spuId){
        List<SpuImage> spuImageList = spuImageService.getSpuImageList(spuId);
        return Result.build(spuImageList, ResultCodeEnum.SUCCESS);
    }
}
